package com.study.funlam;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author zhuzi
 * 2024/7/3 9:11
 */
@Slf4j
public class Demo01 {
    public static String lg() {
        System.out.println("哈哈哈");
        return "a";
    }

    @Test
    public void logs() {
        // 设置日志级别为DEBUG
        Logger logger = LoggerFactory.getLogger(Demo01.class);

        // 获取LoggerContext
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

        // 将Logger的级别设置为DEBUG
        loggerContext.getLogger(Demo01.class.getName()).setLevel(Level.WARN);
        logger.info("{}", log.getClass());
        logger.error("{}", lg());
        logger.warn("{}", lg());
        logger.debug("{}", lg());
    }
}
